// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
// 引用less样式
import '@/style/index.css'
// 引用element-ui插件
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import store from './store/store'
import moment from 'moment'
import { isLogin } from '@/api'
Vue.prototype.$moment = moment
Vue.use(ElementUI)
Vue.config.productionTip = false
/* 导航守卫者 */
router.beforeEach((to, from, next) => {
  isLogin().then(res => {
    if (res.success || to.path === '/login') {
      next()
    } else {
      next({name: 'Login'})
    }
  })
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  store, // 注入
  router,
  components: { App },
  template: '<App/>'
})
